package org.iipg.common.data.autoconfig;

import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/** Author: zhuhy163@163.com Date: 2020/9/5 */
@Configuration
@RequiredArgsConstructor
public class RestTemplateConfig {

//	private final SysRequestMapper sysRequestMapper;
//
//	@Bean
//	public RestTemplateInterceptor restTemplateInterceptor() {
//		return new RestTemplateInterceptor(sysRequestMapper);
//	}

	@Bean
	@ConditionalOnMissingBean(RestTemplate.class)
	public RestTemplate restTemplate(RestTemplateBuilder builder) {
		RestTemplate restTemplate = builder.build();

//		restTemplate.setInterceptors(Collections.singletonList(restTemplateInterceptor()));

		return restTemplate;
	}

}
